<div class="open-form">
    <div class="open-model">
        <div class="open-auto">
            <button class="layui-btn" id="isCheckFun" style="border-radius: 4px;margin-bottom: 10px">确认选择</button>
            <table id="purchaseSignForFormTableTable"></table>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">关闭</button>
        </div>
    </div>
</div>
<script>
    layui.use(['layer', 'form', 'table', 'admin', 'upload', 'tree', 'laytpl'], async function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laytpl = layui.laytpl;
        const nowData = {...parentData}
        console.log(nowData.inventoryTypeCode)
        if (nowData.inventoryTypeCode == "CGR") { //采购入库
            table.render({
                elem: '#purchaseSignForFormTableTable',
                url: config.base + 'enterprise/purchase/admin/purchaseDeliveryRecordProduct/list',
                where: {
                    purchaseDeliveryRecordId: nowData.id,
                    filterSignComplete: 1,
                },
                data: [],
                page: false,
                cellMinWidth: 100,
                cols: [[
                    {type: 'checkbox', fixed: 'left'},
                    {type: 'numbers', width: 70, title: "序号"}
                    , {field: 'id', title: '采购签收任务ID', hide: 'true'}
                    , {field: 'productTypeId', title: '物料类型ID', hide: 'true'}
                    , {
                        field: 'productPic',
                        align: 'center',
                        title: '物料图片',
                        width: 120,
                        hide: 'true',
                        templet: function (d) {
                            return '<img src="' + d.productPic + '" style="height: 40px;" id="platformPic"/>'
                        }
                    }
                    , {field: 'skuCode', align: 'center', title: '物料编号', width: 140}
                    , {field: 'skuName', align: 'center', title: '物料名称', width: 140}
                    , {field: 'skuSpec', align: 'center', title: '规格号', width: 140}
                    , {field: 'baseUnitName', align: 'center', title: '基础单位'}
                    , {
                        field: 'purchaseQuantity', align: 'center', title: '采购数量',
                        templet: function (d) {
                            return d.purchaseQuantity + "" + d.mainUnitName;
                        }
                    }
                    , {
                        field: 'quantity', align: 'center', title: '发货数量',
                        templet: function (d) {
                            return d.quantity + "" + d.mainUnitName;
                        }
                    }
                    , {
                        field: 'hasSignQuantity', align: 'center', title: '签收数量(主计量)', width: 170,
                        templet: function (d) {
                            return d.hasSignQuantity + "" + d.mainUnitName;
                        }
                    }
                    // , {
                    //     field: 'subUnitNum', align: 'center', title: '辅计量单位数', width: 120,
                    // }
                    // , {
                    //     field: 'baseUnitNum', align: 'center', title: '基础单位数',
                    //     // templet: function (d) {
                    //     //     return (d.signNum * d.mainUnitRate) + "" + d.baseUnitName;
                    //     // }
                    // }
                ]]
            });
        }
        // if(nowData.inventoryType)
        // const res = await admin.reqPro(`enterprise/product/admin/productDetailWMS/list`, {})
        // table.reload('purchaseSignForFormTable', {
        //     data: res.data.map(v => {
        //         delete v.id
        //         return v
        //     })
        // })
        $('#isCheckFun').click(() => {
            var checkStatus = table.checkStatus('purchaseSignForFormTableTable'); // 'demo'是表格的ID
            var data = checkStatus.data;  // 选中的数据

            if (typeof parent.layui !== 'undefined') {
                childData.list = data.map(v => {
                    return v
                })
                layer.close(nowData.zindex); // 关闭指定的弹窗
            }
        })

    })
</script>